home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_clone.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  1.8 KB  |  98 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_CLONE
  5.    
  6. inherit 
  7.    ANY
  8.       redefine
  9.      copy, is_equal
  10.       end;
  11.    
  12. creation {ANY}
  13.    make
  14.    
  15. feature {ANY}
  16.    
  17.    s1, s2: STRING;
  18.    a1, a2: ANIMAL;
  19.    
  20.    ai1, ai2: ARRAY[INTEGER];
  21.    
  22.    p1, p2: POINT;
  23.    t1, t2: TRIANGLE;
  24.    
  25.    make is
  26.       local
  27.      test_clone: like Current;
  28.       do
  29.      s1 := "foo";
  30.      s2 := clone(s1);
  31.      is_true(s1 /= s2);
  32.      is_true(equal(s1,s2));
  33.      is_true(s2.capacity >= s2.count);
  34.      s1.put('b',2);
  35.      is_true(not equal(s1,s2));
  36.      
  37.      !CAT!a1;
  38.      a2 := clone(a1);
  39.      is_true(a1 /= a2);
  40.      is_true(equal(a1,a2));
  41.      
  42.      ai1 := <<1,2,3>>;
  43.      ai2 := clone(ai1);
  44.      is_true(equal(ai1,ai2));
  45.      is_true(ai1 /= ai2);
  46.      
  47.      !!p1.make(1,2);
  48.      p2 := clone(p1);
  49.      is_true(p1 /= p2);
  50.      is_true(p1.x = p2.x);
  51.      is_true(p1.y = p2.y);
  52.      is_true(p1.same_type(p2));
  53.      
  54.      !!t1.make(p1,p2,p2);
  55.      t2 := clone(t1);
  56.      is_true(t1 /= t2);
  57.      is_true(t1.same_type(t2));
  58.      is_true(t1.p1 = t2.p1);
  59.      is_true(t1.p2 = t2.p2);
  60.      is_true(t1.p3 = t2.p3);
  61.      is_true(t2.p2 = t2.p3);
  62.      
  63.      test_clone := clone(Current);
  64.      is_true(test_clone.same_type(Current));
  65.      is_true(test_clone.s1 = Void);
  66.      is_true(test_clone.s2 = Void);
  67.      is_true(test_clone.ai1 = Void);
  68.      is_true(test_clone.t1 = Void);
  69.      is_true(test_clone.t2 = Void);
  70.      
  71. -- ???     is_true(3 = clone(3));
  72.       end;
  73.    
  74.    copy(other: like Current) is
  75.       do
  76.       end;
  77.    
  78.    is_equal(other: like Current): BOOLEAN is
  79.       do
  80.      Result := true;
  81.       end;
  82.    
  83.    is_true(b: BOOLEAN) is
  84.       do
  85.      cpt := cpt + 1;
  86.      if not b then
  87.         std_output.put_string("TEST_CLONE: ERROR Test # ");
  88.         std_output.put_integer(cpt);
  89.         std_output.put_string("%N");
  90.      else
  91.         -- std_output.put_string("Yes %N");
  92.      end;
  93.       end;
  94.    
  95.    cpt: INTEGER;
  96.    
  97. end -- TEST_CLONE
  98.